package com.mew.slots.core.game.mymg.service;

import com.alibaba.fastjson.JSON;
import com.mew.common.entity.game.WinFree;
import com.mew.slots.core.common.game.BaseGameService;
import com.mew.slots.core.common.game.vo.BasePlayMsgs;
import com.mew.slots.core.common.messge.response.SlotsPlayResponseMessage;
import com.mew.slots.core.common.vo.StrategyGameVO;
import com.mew.slots.core.game.jg.bo.JgInRoom;
import com.mew.slots.core.game.jg.bo.JgInRoomList;
import com.mew.slots.core.game.jg.bo.JgPlayMsgs;
import com.mew.slots.core.game.jg.message.JgResponseMessage;
import com.mew.slots.core.game.jg.roller.JgXml;
import com.mew.slots.core.game.jg.room.JgRoom;
import com.mew.slots.core.game.mymg.bo.MymgPlayMsgs;
import com.mew.slots.core.game.mymg.message.MymgResponseMessage;
import com.mew.slots.core.game.mymg.roller.MymgIli;
import com.mew.slots.core.game.mymg.roller.MymgXml;
import com.mew.slots.core.game.mymg.room.MymgRoom;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author Dylin
 */
@Service
@Slf4j
public class MymgService extends BaseGameService {
    @Override
    public BasePlayMsgs startGame(StrategyGameVO player) {
        MymgRoom room = new MymgRoom(winFree.getFreeType());
        room.init(player.getRollerId(), MymgIli.getInstance(),player.getWinFree().getFrees()>0,player.getInBetNumber(),player.getControlType());
        room.roundPlayIli();
        return room.getRes();
    }

    @Override
    public SlotsPlayResponseMessage myResp(WinFree winFree, BasePlayMsgs res) {
        MymgResponseMessage message = new MymgResponseMessage();
        MymgPlayMsgs pmres = (MymgPlayMsgs) res;

        message.setRate(pmres.getRate());
        message.setFreeType(pmres.getFreeType());
        message.setBonus(pmres.getBouns());
        if(pmres.getBouns() > 0){
            winFree.setBounsNumber(3);
        }
        if(pmres.getFree()>0 && winFree.getFreeNumber() == 0){
            winFree.setFreeType(pmres.getFreeType());
        }
        if(pmres.getFree() == 0 && winFree.getFrees() >0  && winFree.getFreeNumber() == 1){
            winFree.setFreeType(0);
        }
        return message;
    }
    @Override
    public void myAfterResp(SlotsPlayResponseMessage message,StrategyGameVO player, BasePlayMsgs res) { }
}
